package org.example.travel_web.controller.user;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.example.travel_web.dto.PageResult;
import org.example.travel_web.dto.attr.AttrPageReq;
import org.example.travel_web.dto.attr.AttrPageResp;
import org.example.travel_web.dto.attr.AttrReq;
import org.example.travel_web.service.UserAttrService;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user/attr")
@Tag(name = "用户收藏")
public class UserAttrController {

    @Resource
    private UserAttrService userAttrService;


    @GetMapping
    @Operation(summary = "收藏分页查询")
    public PageResult<AttrPageResp> pageResult(@Valid AttrPageReq req) {
        return userAttrService.pageResult(req);
    }

    @PostMapping
    @Operation(summary = "添加收藏")
    public void add(@Valid AttrReq req) {
        userAttrService.add(req);
    }

    @PutMapping
    @Operation(summary = "取消收藏")
    public void cancel(@Valid AttrReq req) {
        userAttrService.cancel(req);
    }

    @DeleteMapping
    @Operation(summary = "删除收藏")
    @Parameter(name = "ids", description = "收藏 ID 数组", required = true, in = ParameterIn.QUERY)
    public void delete(@RequestParam Long[] ids) {
        userAttrService.delete(ids);
    }
}
